#ifndef _MESSAGE_H_
#define _MESSAGE_H_

#define 	MSG_HEAD_LEN_SZ			2
#define 	MSG_DATA_BUFF_SZ		256
#include "at.h"
/*
1.信号强度，Profile中可定义为：RSRP、rsrp、signalStrength、SignalPower，数据类型为int，上报范围应在-140至-40之间

2.覆盖等级，Profile中可定义为：ECL、signalECL，数据类型为int，上报范围应在0至2之间

3.信噪比，Profile中可定义为：SNR、snr、SINR、sinr、signalSNR，数据类型为int，上报范围应在-20至30之间

4.小区覆盖等级，Profile中可定义为：CellID、cellId，数据类型为int，上报范围应在0至2147483647之间 
*/
typedef struct message_t{
	int iFd;
	
	char acIP[20];
	unsigned short usPort;
	unsigned char aucMsgData[MSG_DATA_BUFF_SZ+1], ucStaFlag;
	unsigned short usMsgLen, usRevLen;
	
	unsigned char aucSN[32],
								aucModule[16],
								aucModuleVer[32],
								aucIMSI[16],
								aucIMEI[16],
								aucSignal[3],
								aucAPaddr[19],
								aucLBS[14],
								ucECL,
								acRegSta, acNetType;
	unsigned short usVoltage,
								 usLight,
								 usSound,
								 usHumi;
	int iTemp;
	unsigned char ucLED, ucSwitch1, ucSwitch2;
	
	unsigned char ucACK,
								ucHeartbeat,
								ucActive,
							  ucCmd,
								ucCmdVal,
								aucCmdMsg[17],
								aucMsgID[5];
	int iRSRP, iSNR, iCellID;							
}Message;

typedef enum MSG_CMD_t{
	MSG_ACK = 0x30,
	
	CTL_LED = 1,
	CTL_LCD = 2,
	CTL_SWITCH_1 = 3,
	CTL_SWITCH_2 = 4,
	CTL_SWITCH_12 = 5,
}MSG_CMD;

void printf_hex(char *pcPrefix, unsigned char *pucData, int iLen);

int pack_module_info_message(Message *pstMsg);
int pack_senser_info_message(Message *pstMsg);
int pack_ack_message(Message *pstMsg);
int pack_heartbeat_message(Message *pstMsg);

int pack_huawei_senser_info_msg(Message *pstMsg);
int pack_huawei_ctl_ack_msg(Message *pstMsg);
int parse_msg(Message *pstMsg);

int parse_coap_msg(Message *pstMsg);
#endif


